﻿using System.Windows.Controls;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using StartupSolution.ViewModel;

namespace StartupSolution.Views.Timelines
{
    public partial class EventSelection : Page
    {
        public EventSelection()
        {
            InitializeComponent();
        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            TimelineDataViewModel viewModel = new TimelineDataViewModel();
            Timeline.DataContext = viewModel;

            //Timeline.Zoombar.ZoomChanged += new EventHandler<Infragistics.Controls.ZoomChangedEventArgs>(Zoombar_ZoomChanged);
            //Timeline.Zoombar.ZoomChanging += new EventHandler<Infragistics.Controls.ZoomChangeEventArgs>(Zoombar_ZoomChanging);
        }

        //TODO: Add custom logic for the xamTimeline events handling.

        void Zoombar_ZoomChanging(object sender, Infragistics.Controls.ZoomChangeEventArgs e)
        {
            SetText("Zoom changing...new range: " + e.NewRange);
        }

        void Zoombar_ZoomChanged(object sender, Infragistics.Controls.ZoomChangedEventArgs e)
        {
            SetText("Zoom changed! New range: " + e.NewRange);
        }

        private void DateTimeAxis_SelectedTimeChanged(object sender, Infragistics.Controls.Timelines.DateTimeChangedEventArgs e)
        {
            SetText(e.NewTime.ToString("d"));
        }

        #region Output
        private void SetText(string text)
        {
            textBlockOutput.Text += text + "\r\n";
            scrollViewer.ScrollToVerticalOffset(double.MaxValue);
        }
        #endregion
    }
}
